package 匿名内部类重点;

public class test2 {
    public static void main(String[] args) {
        Swim a=new Swim() {
            @Override
            public void swim() {
                System.out.println("游泳");
            }
        };a.swim();
        goSwim(a);
        goSwim(new Swim(){

            @Override
            public void swim() {
                System.out.println("不会游泳");
            }
        }/* 一个参数*/);
//        Swim b =new Swim() {
//            @Override
//            public void swim() {
//                System.out.println("不会游泳");
//            }
//        };
//        goSwim(b);//就是上面那个的全体版
    }
    public static void goSwim(Swim s){
        s.swim();
    }
}
interface Swim{
    void swim();
}

